import myfetch from "./myfetch"
import token from "./token"
import use from "./user"
let user = use.getMyInfo()
export default {
  getQ(id: string) {
    let param = {
      id
    }
    return myfetch.myget('/message/getQ', param)
  },
  getNews(id: string) {
    let param = {
      id
    }
    return myfetch.myget('/message/getNews', param)
  },
  getMyMessage(isNews?: string) {
    let param = { id: token.getToken(), isNews }
    isNews ? param.isNews = "1" : null
    return myfetch.myget('/message/getMyMessage', param)
  },
  getCanUp(workid: string) {
    let param = {
      pid: user.id as string,
      workid
    }
    return myfetch.myget('/message/getCanUp', param)
  },
  upQ(id: string, type: string, message: string) {
    let param = {
      id,
      type,
      token: token.getToken()
    }
    let body = {
      message
    }
    return myfetch.mypost('/message/upQ', param, body)
  },
  upNews(id: string, message: string) {
    let param = {
      id,
      token: token.getToken()
    }
    let body = {
      message
    }
    return myfetch.mypost('/message/upNews', param, body)
  },
  setWrite(id: string, setWrite: string, isNews?: string) {
    let param: Record<string, any> = {
      id,
      setWrite
    }
    isNews && (param.isNews = "1")
    return myfetch.myget('/message/setWrite', param)
  },
  setQImg(id: string, imgurls: string) {
    let param = {
      id
    }
    let body = {
      imgurls
    }
    return myfetch.mypost('/message/setQImg', param, body)
  },
  creat(id: string, fromid: string, uptime: string, isNews: string) {
    let param = {
      id,
      fromid,
      uptime,
      isNews
    }
    isNews ? param.isNews = "1" : null
    return myfetch.myget('/message/create', param)
  },
}
